package cn.rkylin.oms.base.resendReasonType.dao;

import cn.rkylin.core.IDataBaseFactory;
import cn.rkylin.oms.base.resendReasonType.vo.ResendReasonVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * Created by Administrator on 2018-3-21.
 */
@Repository(value = "resendReasonTypeDAO")
public class ResendReasonTypeDAOImpl implements IResendReasonTypeDAO{

    @Autowired
    protected IDataBaseFactory dao;

    /**
     * 构造函数
     */
    public ResendReasonTypeDAOImpl() {

    }
    @Override
    public ResendReasonVO findById(String id) throws Exception {
        List<ResendReasonVO> resultList = dao.findList("selectByPrimaryKeyResendReason", id);
        if (resultList != null && resultList.size() > 0) {
            return resultList.get(0);
        }
        return null;
    }

    @Override
    public ResendReasonVO findByName(String name) throws Exception {
        List<ResendReasonVO> resultList = dao.findList("selectByNameResendReason", name);
        if (resultList != null && resultList.size() > 0) {
            return resultList.get(0);
        }
        return null;
    }

    @Override
    public ResendReasonVO findByCode(String code) throws Exception {
        List<ResendReasonVO> resultList = dao.findList("selectByCodeResendReason", code);
        if (resultList != null && resultList.size() > 0) {
            return resultList.get(0);
        }
        return null;
    }

    @Override
    public int insert(ResendReasonVO resendReasonVO) throws Exception {
        return dao.insert("insertSelectiveResendReason",resendReasonVO);
    }

    @Override
    public int update(ResendReasonVO resendReasonVO) throws Exception {
        return dao.update("updateByPrimaryKeySelectiveResendReason",resendReasonVO);
    }

}
